/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}

export function validTelephone(value) {
  return /^(0\d{2,3}\-)?([2-9]\d{6,7})+(\-\d{1,6})?$/.test(value)
}

export function validPhone(value) {
  return /^((\+86|\+86\-)|(86|86\-)|(0086|0086\-))?1[3|5|7|8]\d{9}$/.test(value)
}

export function validUserName(value) {
  return /^[A-Za-z0-9]+$/.test(value)
}
